<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>借阅点详情</title>
  <link rel="stylesheet" href="css/base.css">
  <link rel="stylesheet" href="css/my.css">
  <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1, user-scalable=no">
  <script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=CZGWTuDCeuuheObPUjaHkXfDSI2xulRU"></script>
</head>
<body>
<div class="header-box">
  <p>借阅点详情</p>
</div>
<div class="lendSiteDetails">
  <div class="lendSiteDetails_box">
    <div class="map" id="allmap"></div>
  </div>
  <div class="lendSiteDetails_text">
    <p><i style="font-size: 0.3rem" id="myPlaceName"></i></p>
    <p>
    <span>地址：<i id="myAddress"></i></span><br>
    <span>营业时间：<i id="myPlaceDesc"></i></span>
    
    </p>
  </div>
</div>
<div class="set_my_common_place">
  <a id="addMyLendSite" href="javascript:void(0)">选为我的常用地点</a>
</div>
</body>
<script src="js/jquery.js"></script><script src="js/jquery.cookie.js"></script>
<script src="js/base.js?v=base.js?v=20180102"></script>
<script type="text/javascript">

var id = getQueryString("id");

if(id != null){
loadDataDetail();
}

// 设置新的默认借阅点
$("#addMyLendSite").click(function(){
	
	$.post({
		url : window.baseUrl + '/api/book/user/update',
		data : JSON.stringify({
			id : getUserId(),
			firstBorrowId : id
		}),
		contentType: "application/json",
		success : function(data) {
			$.cookie("firstBorrowId",id);
			window.location.href = "setLendSite.html";
		}
	});
});


//查询借阅点详情
function loadDataDetail(){
//   var firstBorrowId = $.cookie("firstBorrowId");
//   if(firstBorrowId != null){
	$.get({
		url : window.baseUrl + "/api/book/borrowPlace/find",
		data : {
			id : id
		},
		success : function(data) {
			var data = data.data;
			if(data != null){
				$("#myPlaceName").text(data.placeName);
				$("#myAddress").text(data.address);
				$("#myPlaceDesc").text(data.placeDesc);
				showMap(data.latitude, data.longitude);
			}
		}
	});	
//  }
}

function showMap(longitude,latitude){
//   // 百度地图API功能
  var map = new BMap.Map("allmap");    // 创建Map实例
  var point = new BMap.Point(latitude, longitude);
  map.centerAndZoom(point, 14);  // 初始化地图,设置中心点坐标和地图级别
  //添加地图类型控件
  map.addControl(new BMap.MapTypeControl({
    mapTypes:[
      BMAP_NORMAL_MAP,
      BMAP_HYBRID_MAP
    ]}));
  map.setCurrentCity("北京");          // 设置地图显示的城市 此项是必须设置的
  map.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放

  var mk = new BMap.Marker(point);
  mk.setAnimation(BMAP_ANIMATION_BOUNCE);
  map.addOverlay(mk);
  
}  
</script>
</html>